home *** CD-ROM | disk | FTP | other *** search
- Path: news.ov.com!news
- From: glenn@ov.com (Fletcher.Glenn@ov.com)
- Newsgroups: comp.lang.c
- Subject: Re: Question on pointer-to-pointer-to-pointer
- Date: 23 Jan 1996 21:48:21 GMT
- Organization: OpenVision
- Message-ID: <4e3l35$j22@spanky.pls.ov.com>
- References: <4dq2ej$m3t@cssun.cs.usm.my>
- Reply-To: glenn@ov.com
- NNTP-Posting-Host: foghorn.pls.ov.com
-
- In article m3t@cssun.cs.usm.my, bahari@cs.usm.my (Bahari Belaton (Dr)) writes:
- >Hi,
- >Below is one of the question asked by my student about pointer-to-pointer in
- >C - with a specific example on strtod() function. Can anyone help me explain
- >this to my student. Especially on the important of pointer-to-pointer.
- >
- >Thanks
- >
- >Bahari Belaton
- >
- >=======================================================================
- >Dear All,
- > I hope you can enlighthen me a bit.
- >Query 1:
- > According to Deitel, the function prototype for strtod() is:-
- > double strtod(const char *nPtr, char **endPtr) and the function call is
- >as follows :-
- > double d;
- > char *string = "51.2% are admitted";
- > char *stringPtr;
- >
- > d = strtod(string, &stringPtr);
- >
- >The book says that &stringPtr is assigned the location of the first character
- >after the converted value. How does the function do that?
-
- Remember, a function cannot modify an argument unless the argument is a pointer
- to the object to be modified. Thus if you want the strtod() function to
- set a pointer to the next character, you must supply a pointer to the
- memory location to contain the result (a char *). Of course &(char *) is
- a char **.
-
- >
- >I'm still confused with **endPtr. Why the **endPtr(pointer to a
- >pointer) is used?(What is the significance of using a double pointer? Why
- >not just *endPtr since the function assigned the address of first
- >character of the string to &stringPtr. (what about***endPtr?
- >How many pointers to pointer can we used?)
-
- The number of levels of indirection is usually limited by human understanding
- before it is limited by the compiler. Most programs do not use more than
- 3 levels of indirection.
-
- >
- >Thank you very much.
- >Your student,
- >LEE KENG TUNG csi36864@wira2.cs.usm.my
- >
- >=================================
-
-
- Fletcher.Glenn@ov.com
-
-